package com.yonyou.pmclouds.contacttype.service.rmiimpl;

import java.util.ArrayList;
import java.util.List;

import com.yonyou.pmclouds.offline.aspect.Offline;
import com.yonyou.pmclouds.offline.entity.OffLineDataKeyConst;
import com.yonyou.pmclouds.offline.entity.OffLineInvocationContext;
import com.yonyou.pmclouds.offline.rmiitf.IOffLineDataQueryService;
import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.druid.util.StringUtils;
import com.alibaba.dubbo.config.annotation.Service;
import com.yonyou.pmclouds.ApplicationConsts;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.contacttype.entity.ContactTypeRefVO;
import com.yonyou.pmclouds.contacttype.entity.ContactTypeVO;
import com.yonyou.pmclouds.contacttype.mapper.ContactTypeMapper;
import com.yonyou.pmclouds.contacttype.service.rmiitf.ContactTypeRemoteMobService;

import lombok.Data;

@Data
@Service(version = ApplicationConsts.APPLICATION_VERSION, interfaceClass = ContactTypeRemoteMobService.class)
@Offline(dataFrom = OffLineDataKeyConst.DATA_FROM_CONTRACT_TYPE)
public class ContactTypeRemoteMobServiceImpl implements ContactTypeRemoteMobService, IOffLineDataQueryService{
	
	@Autowired
    private ContactTypeMapper contactTypeMapper;
	
	public List<ContactTypeRefVO> queryConTypesByProject(String pk_project) {
		
		List<ContactTypeRefVO> resultList = new ArrayList<ContactTypeRefVO>();
		resultList = contactTypeMapper.selectByProject(pk_project);
		return resultList;
	}

    @Override
    public ContactTypeVO queryById(String id) throws BusinessException {
        if(StringUtils.isEmpty(id)) {
            return null;
        }
        return contactTypeMapper.getById(id);
    }

    @Override
    public Object queryOffLineData(OffLineInvocationContext invocationContext) throws BusinessException {
        return contactTypeMapper.selectByPkGroup(invocationContext.getTenantId());
    }
}
